﻿using Shop.Application.Orders.Dto;
using Shop.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shop.Application.Orders
{
    public class GetOrdersByUserName
    {
        private DBContext _context;

        public GetOrdersByUserName(DBContext context)
        {
            _context = context;
        }

        public List<OrderDto> Do(string userName) =>
           _context.Orders.Where(x => x.UserName == userName)
                .Select(y => new OrderDto
                {
                    OrderName = y.OrderName,
                    UserName = y.UserName,
                    Email = y.Email,
                    PhoneNumber = y.PhoneNumber,
                    Address = y.Address,
                    City = y.City,
                    PostCode = y.PostCode
                })
                .ToList();
    }
}
